<extend name="Public/base" />

<!-- 子導航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>

<block name="body">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    
	<div class="main-title cf">
		<h2>
		出租
		</h2>
	</div>
	<!-- 標簽頁導航 -->
<div class="tab-wrap">
<!--	<ul class="tab-nav nav">
		<volist name=":parse_config_attr($model['field_group'])" id="group">
			<li data-tab="tab{$key}" <eq name="key" value="1">class="current"</eq>><a href="javascript:void(0);">{$group}</a></li>
		</volist>
	</ul>-->
	<div class="tab-content">
    <style>
table{ width:100%; border-collapse:collapse; font-size:13px; background: #fff; margin-bottom: 10px}
table tr{ width:100%; height:50px;}
table tr td{ border:1px #ccc solid; padding-left:15px;}
.text1{ width:70%; height:50px; border:0; padding-left:10px; line-height:50px;}
.text2{ width:70%; height:90px; border:0; vertical-align:middle; padding:10px; line-height:15px; overflow: hidden; font-size: 12px}
</style>
              <table  id="printContent">
  <tr>
    <td colspan="3" style="text-align:center;">出租委託</td>
  </tr>
  <tr>
    <td>街道：<input readonly  type="text" class="text1"  value="{$data.street}"></td>
    <td>區域：<input readonly type="text" class="text1"  value="{$data.range}"></td>
    <td>面積：<input readonly type="text" class="text1" value="{$data.area}"></td>
  </tr>
  <tr>
    <td>戶型：<input readonly  type="text" class="text1" value="{$data.house_type}"></td>
    <td>類型：<input readonly  type="text" class="text1" value="{$data.types}"></td>
    <td>樓層：<input readonly  type="text" class="text1" value="{$data.floor}"></td>
  </tr>
  <tr>
    <td>租期：<input  readonly type="text" class="text1" value="{$data.rantaltime}"></td>
    <td colspan="2">現狀：<input readonly type="text" class="text1" value="{$data.statused}"></td>
  </tr>
  <tr>
    <td>價格：<input readonly type="text" class="text1" value="{$data.fee}MOP"></td>
    <td colspan="2">包含管理費：<input readonly type="text" class="text1"></td>
  </tr>
  <tr>
    <td colspan="3">物業地址：<input readonly type="text" class="text1" value="{$data.address}"></td>
  </tr>
  <tr>
    <td colspan="3">裝修程度：<input readonly type="text" class="text1" value="{$data.finish}"></td>
  </tr>
  <tr>
    <td colspan="3">配套設施：<input readonly type="text" class="text1" value="{$data.device}"></td>
  </tr>
  <tr>
    <td colspan="3">訂金要求：<input readonly type="text" class="text1" value="{$data.foregift}"></td>
  </tr>
  <tr>
    <td colspan="3">房屋描述：<textarea readonly class="text2" >{$data.description}</textarea></td>
  </tr>
  <tr>
      <td colspan="3">物業圖片：
     <div class="form-item cf">
                 
                    <div class="controls">

    
 <div class="upload-img-box">
       <notempty name="data.photo">
        <volist name='photo' id='vo2'>
        <div class="upload-pre-item" style=' float: left; border: 0'>
                    <img style=' margin: 5px; border: 0' src="__ROOT__{:get_cover($vo2,$field = path)}" data-id="{$vo2}">
                </div>
        </volist>
                   </notempty>
 
    </div>
                            <script type="text/javascript">
    //上传图片
$(function(){
        /* 初始化上传插件*/
      
        $("#upload_picture_photo").uploadify({
            "height"          : 30,
            "swf"             : "/sf/Public/static/uploadify/uploadify.swf",
            "fileObjName"     : "download",
            "buttonText"      : "上传图片",
            "uploader"        : "/sf/index.php?s=/Admin/File/uploadPicture/session_id/2pieuumh72k3igkgkiruk66av4.html",
            "width"           : 120,
            'removeTimeout'   : 1,
            'fileTypeExts'    : '*.jpg; *.png; *.gif;',
            "onUploadSuccess" : uploadPicturephoto,
            'onFallback' : function() {
                alert('未检测到兼容版本的Flash.');
            }
        });
        $('.btn-close-photo').click(function(event) {
            
            event.preventDefault();
            $(this).parent().remove();
            picsbox = $("#upload_picture_photo").siblings('.upload-img-box');
            picArr = [];
            for (var i = 0; i < picsbox.children().length ; i++) {
                picArr.push(picsbox.children('.upload-pre-item:eq('+i+')').find('img').attr('data-id'));
            };
            picStr = picArr.join(',');
            $('.icon.photo').val(picStr);
        });
})
    function uploadPicturephoto(file, data){
        var data = $.parseJSON(data);
        var src = '';
        if(data.status){
            src = data.url || '/sf' + data.path;
            upload_img = "<div class='upload-pre-item'><img src=" + src +" title='点击显示大图' data-id="+data.id+"> <span class='btn-close btn-close-photo' title='删除图片'></span></div>";
            picsbox = $("#upload_picture_photo").siblings('.upload-img-box');
            picsbox.append(upload_img)
            picArr = [];
            for (var i = 0; i < picsbox.children().length ; i++) {
                picArr.push(picsbox.children('.upload-pre-item:eq('+i+')').find('img').attr('data-id'));
            };
            picStr = picArr.join(',');
            $('.icon.photo').val(picStr);
        } else {
            updateAlert(data.info);
            setTimeout(function(){
                $('#top-alert').find('button').click();
                $(that).removeClass('disabled').prop('disabled',false);
            },1500);
        }
    }
</script>                    </div>
                </div>
      </td>
  </tr>
  <tr>
    <td colspan="3" style="border-bottom:0;">委託人聯繫方式：</td>
  </tr>
  <tr>
    <td style="border:0; border-left:1px #ccc solid;">姓名：<input readonly type="text" class="text1" value="{$data.wname}"></td>
    <td style="border:0;">電話：<input readonly type="text" class="text1" value="{$data.tel}"></td>
    <td style="border:0; border-right:1px #ccc solid;">郵箱：<input readonly type="text" class="text1" value="{$data.email}"></td>
  </tr>
  <tr>
    <td colspan="3" style="border-top:0;">地址：<input readonly type="text" class="text1" value="{$data.adds}"></td>
  </tr>
  <tr>
    <td colspan="3" style="border-top:0;">委託時間：<input readonly type="text" class="text1" value="{$data.create_time|date='Y-m-d',###}"></td>
  </tr>
  
</table>
<script>
//打印
(function($) {  
var printAreaCount = 0; 
$.fn.printArea = function() {  
var ele = $(this);  
var idPrefix = "printArea_";  
removePrintArea( idPrefix + printAreaCount ); 
printAreaCount++;  
var iframeId = idPrefix + printAreaCount; 
var iframeStyle = 'position:absolute;width:0px;height:0px; font-size:12px'; 
iframe = document.createElement('IFRAME'); 
$(iframe).attr({ style : iframeStyle, id    : iframeId });
document.body.appendChild(iframe); 
var doc = iframe.contentWindow.document;
$(document).find("link").filter(function(){  
return $(this).attr("rel").toLowerCase() == "stylesheet"; 
}).each(function(){
doc.write('<link type="text/css" rel="stylesheet" href="' +$(this).attr("href") + '" >'); 
});  
doc.write('<div class="' + $(ele).attr("class") + '">' + $(ele).html() + '</div>'); 
doc.close();  
var frameWindow = iframe.contentWindow; 
frameWindow.close(); 
frameWindow.focus(); 
frameWindow.print(); 
}  
var removePrintArea = function(id) 
{  
$( "iframe#" + id ).remove(); 
};  
})(jQuery);
</script>
  <script type="text/javascript"> 
    $(function(){ 
    $("#btnPrint").click(function() { 
        $(".tab-content").printArea(); 
    }); 
});
 </script>          
		<div class="form-item cf" style=" margin-left: 40%">
			<button class="btn  btn-return"  id="btnPrint">列印</button>
			<a class="btn btn-return" href="{$Think.cookie.__forward__}">返 回</a>
			<if condition="C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)">
			</if>
			<input type="hidden" name="id" value="{$data.id|default=''}"/>
			<input type="hidden" name="pid" value="{$data.pid|default=''}"/>
			<input type="hidden" name="model_id" value="{$data.model_id|default=''}"/>
			<input type="hidden" name="category_id" value="{$data.category_id|default=''}">
		</div>
	</div>
</div>
</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">

Think.setValue("type", {$data.type|default='""'});
Think.setValue("display", {$data.display|default=0});



$(function(){
    $('.time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });
    showTab();

	<if condition="C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)">
	//保存草稿
	var interval;
	$('#autoSave').click(function(){
        var target_form = $(this).attr('target-form');
        var target = $(this).attr('url')
        var form = $('.'+target_form);
        var query = form.serialize();
        var that = this;

        $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
        $.post(target,query).success(function(data){
            if (data.status==1) {
                updateAlert(data.info ,'alert-success');
                $('input[name=id]').val(data.data.id);
            }else{
                updateAlert(data.info);
            }
            setTimeout(function(){
                $('#top-alert').find('button').click();
                $(that).removeClass('disabled').prop('disabled',false);
            },1500);
        })

        //重新開始定時器
        clearInterval(interval);
        autoSaveDraft();
        return false;
    });

	//Ctrl+S保存草稿
	$('body').keydown(function(e){
		if(e.ctrlKey && e.which == 83){
			$('#autoSave').click();
			return false;
		}
	});

	//每隔壹段時間保存草稿
	function autoSaveDraft(){
		interval = setInterval(function(){
			//只有基礎信息填寫了，才會觸發
			var title = $('input[name=title]').val();
			var name = $('input[name=name]').val();
			var des = $('textarea[name=description]').val();
			if(title != '' || name != '' || des != ''){
				$('#autoSave').click();
			}
		}, 1000*parseInt({:C('DRAFT_AOTOSAVE_INTERVAL')}));
	}
	autoSaveDraft();

	</if>

});
</script>

</block>
